<?php
class Model_Articles extends Core_Database
{
     /**
     * Lay noi dung mot bai viet la bai gioi thieu
     * Bai viet co group_index = 1 va moi nhat
     * @param : void
     * @return : string
     * */
    public function getPresentation()
    {
        $sql = 'select content from articles where group_index = 1 order by article_id DESC LIMIT 1 ';
        $sth = $this->_db->prepare($sql);
        $status = $sth->execute();
        if (!$status)
            return "";
        $result = $sth->fetchAll();
        if(count($result)>0)
           return $result[0]['content'];
        else
           return "";  
    }
    
     /**
     * Lay noi dung mot bai viet la bai huong dan
     * Bai viet co group_index = 2 va moi nhat
     * @param : void
     * @return : string
     * */
    public function getInstruction()
    {
        $sql = 'select content from articles where group_index = 2 order by article_id DESC LIMIT 1 ';
        $sth = $this->_db->prepare($sql);
        $status = $sth->execute();
        if (!$status)
            return "";
        $result = $sth->fetchAll();
        if(count($result)>0)
           return $result[0]['content'];
        else
           return "";  
    }
    
  /**
     * Lay noi dung mot bai viet la bai download
     * Bai viet co group_index = 3 va moi nhat
     * @param : void
     * @return : string
     * */
    public function getDownload()
    {
        $sql = 'select content from articles where group_index = 3 order by article_id DESC LIMIT 1 ';
        $sth = $this->_db->prepare($sql);
        $status = $sth->execute();
        if (!$status)
            return "";
        $result = $sth->fetchAll();
        if(count($result)>0)
           return $result[0]['content'];
        else
           return "";  
    }
}